#ifndef THINK_THINK_DB_BUILDER_PGSQL_H
#define THINK_THINK_DB_BUILDER_PGSQL_H

static char* think_db_builder_pgsql =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: liu21st <liu21st@gmail.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\db\\builder;\n"
	"\n"
	"use think\\db\\Builder;\n"
	"\n"
	"/**\n"
	" * Pgsql数据库驱动\n"
	" */\n"
	"class Pgsql extends Builder\n"
	"{\n"
	"    protected $insertSql    = \'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%\';\n"
	"    protected $insertAllSql = \'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%\';\n"
	"\n"
	"    /**\n"
	"     * limit分析\n"
	"     * @access protected\n"
	"     * @param mixed $limit\n"
	"     * @return string\n"
	"     */\n"
	"    public function parseLimit($limit)\n"
	"    {\n"
	"        $limitStr = \'\';\n"
	"        if (!empty($limit)) {\n"
	"            $limit = explode(\',\', $limit);\n"
	"            if (count($limit) > 1) {\n"
	"                $limitStr .= \' LIMIT \' . $limit[1] . \' OFFSET \' . $limit[0] . \' \';\n"
	"            } else {\n"
	"                $limitStr .= \' LIMIT \' . $limit[0] . \' \';\n"
	"            }\n"
	"        }\n"
	"        return $limitStr;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 字段和表名处理\n"
	"     * @access protected\n"
	"     * @param mixed  $key\n"
	"     * @param array  $options\n"
	"     * @return string\n"
	"     */\n"
	"    protected function parseKey($key, $options = [], $strict = false)\n"
	"    {\n"
	"        if (is_numeric($key)) {\n"
	"            return $key;\n"
	"        } elseif ($key instanceof Expression) {\n"
	"            return $key->getValue();\n"
	"        }\n"
	"\n"
	"        $key = trim($key);\n"
	"        if (strpos($key, \'$.\') && false === strpos($key, \'(\')) {\n"
	"            // JSON字段支持\n"
	"            list($field, $name) = explode(\'$.\', $key);\n"
	"            $key                = $field . \'->>\\\'\' . $name . \'\\\'\';\n"
	"        } elseif (strpos($key, \'.\')) {\n"
	"            list($table, $key) = explode(\'.\', $key, 2);\n"
	"            if (\'__TABLE__\' == $table) {\n"
	"                $table = $this->query->getTable();\n"
	"            }\n"
	"            if (isset($options[\'alias\'][$table])) {\n"
	"                $table = $options[\'alias\'][$table];\n"
	"            }\n"
	"        }\n"
	"        if (isset($table)) {\n"
	"            $key = $table . \'.\' . $key;\n"
	"        }\n"
	"        return $key;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 随机排序\n"
	"     * @access protected\n"
	"     * @return string\n"
	"     */\n"
	"    protected function parseRand()\n"
	"    {\n"
	"        return \'RANDOM()\';\n"
	"    }\n"
	"\n"
	"}\n"
	"\n"
;
#endif